#include "DXUT.h"
#include "debug_new.h"
#ifdef _DEBUG
 
  _CriSec _cs;

 //void _RegDebugNew( void )
 //{
	// _CrtSetDbgFlag( _CRTDBG_REPORT_FLAG | _CRTDBG_LEAK_CHECK_DF );
 //}
 

  #undef new
   void* __cdecl operator new( size_t nSize, const char* lpszFileName, int nLine )
  {

	 _cs.Enter();
  void* p = _malloc_dbg( nSize, _NORMAL_BLOCK, lpszFileName, nLine );
  _cs.Leave();
	  return p;
 }
   void __cdecl operator delete( void* p, const char* /*lpszFileName*/, int /*nLine*/ )
  {
	  _cs.Enter();
	  _free_dbg( p, _CLIENT_BLOCK );
 	 _cs.Leave();
 }

#endif
